package org.behrang.macbeans.tab.coda;

import apple.laf.CUIAquaPanel;
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
import javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;

/**
 *
 * @author Behrang Saeedzadeh <behrangsa@gmail.com>
 */
public class CodaPanelUI extends CUIAquaPanel {
    
    public static ComponentUI createUI(JComponent c) {
        return new CodaPanelUI();        
    }
    
    public static Color UPPER_LINE = new Color(202, 202, 202);
    public static Color UPPER_BG = new Color(252, 252, 252);
    public static Color MIDDLE_BG = new Color(243, 243, 243);
    public static Color LOWER_BG = new Color(230, 230, 230);

    @Override
    public void paint(Graphics gr, JComponent c) {
        Graphics2D g = (Graphics2D) gr;        
        if ("statusLine".equals(c.getName())) {
            Rectangle bounds = c.getBounds();

            g.setColor(UPPER_LINE);
            g.drawLine(0, 0, bounds.width, 0);

            GradientPaint gp = new
                    GradientPaint(0, 1, UPPER_BG, 0, bounds.height / 2, MIDDLE_BG);
            Rectangle2D.Double bg = new
                    Rectangle2D.Double(0, 1, bounds.width, bounds.height / 2);
            g.setPaint(gp);
            g.fill(bg);

            g.setColor(LOWER_BG);
            g.fillRect(0, bounds.height / 2, bounds.width, bounds.height / 2 - 1);
        } else {
            super.paint(g, c);
        }
    }
}
